package com.flyxteam.learner.springboot.health;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

import com.flyxteam.learner.springboot.data.SomeData;

// ## 一个HealthIndicator，用于健康判定
@Component
public class SomeHealthIndicator implements HealthIndicator {

    @Autowired
    SomeData someData;
    
    @Override
    public Health health() {
        if ("HDY".equalsIgnoreCase(someData.getInfo().get("name").toString())) {
            return Health.down().withDetail("ERROR", "Info name is not correct.").build();
        }
        return Health.up().build();
    }
    
}
